#!/home/joshua/.guix-profile/bin/guile \
-e main -s
!#

(define (main args)
  (define number (car (cdr args)))
  (display (cube (string->number number) (string->number number)))
  (display "\n"))

;;Implementing a cube root procedure
;; This uses a recursive function to do so.
;; ((x / (y * y)) + 2y) / 3
;; This function is really SLOW.  Calculating the cube root of 1000, takes FOREVER.
;; It tries to aproximate the cube
(define (cube number apr)
  ;; The estimate has to be within .001 of the actual number.
  (define (good-enough?)
    (< (abs (- number (* apr apr apr))) 0.001))
  (define (improve-apr)
    (set! apr (/
               (+
                (* 2 apr)
                (/ number
                   (* apr apr)))
               3)))
  (improve-apr)
  (if (good-enough?)
      (exact->inexact apr)
      (cube number apr)))


(define (A x y)
  (cond ((= y 0) 0)
        ((= x 0 ) (* 2 y))
        (else (A (- x 1)
                 (A x (- y 1))))))
